package postmortem;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;
import java.awt.geom.Line2D;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.IOException;
import java.lang.reflect.Method;
import java.text.AttributedCharacterIterator;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JRootPane;
import javax.swing.SwingUtilities;
import javax.swing.tree.DefaultMutableTreeNode;

public class Tracing {
	public static ArrayList<MethodParam> calledMethods = new ArrayList<MethodParam>();
	static HashMap<String, Method> methods = new HashMap<String, Method>();
	public static LinkedList<Integer> index = new LinkedList<Integer>();
	static String methodName;
	static LinkedList<String> params;
	static String sourceLocation;
	static String command;
	static String rest;
	static int hashcode;
	static long start = System.currentTimeMillis();
	static long end;
	static long ex;
	static int id = 0;
	static int lastHash = 0;
	static Object[] arguments;
	static Object[] returnArgs;
	public static boolean stop = false;
	static boolean initially = true;
	public static JComponent panel;
	static String[] loader = { "a" };
	public static BufferedImage testimg;
	public static BufferedImage testimg1;
	public static LinkedList<BufferedImage> imgList = new LinkedList<BufferedImage>();
	// static record.afterFinish af = new record.afterFinish(loader);
	public static JFrame mainFrame;
	public static Point componentLocation = new Point();
	public static int graphicsHashcode;
	public static DefaultMutableTreeNode root;
	public static boolean once = true;
	public static HashMap<Integer, Object> objects = new HashMap<Integer, Object>();
	public static HashMap<Integer, Graphics> graphicsAndObjects = new HashMap<Integer, Graphics>();
	public static Graphics publicGr;
	public static Component publicComp;
	public static AffineTransform affine;
	public static HashMap<Integer, ArrayList<MethodParam>> objectMethods = new HashMap<Integer, ArrayList<MethodParam>>();
	public static LinkedList<Integer> prova = new LinkedList<Integer>();
	public static LinkedList<Integer> prova2 = new LinkedList<Integer>();
	public static ArrayList<MethodParam> allMethods = new ArrayList<MethodParam>();

	static int idd = 0;
	static int idd2 = 0;
	static Color publicColor = Color.BLACK;
	public static String lastColorLocation = "";
	static Stroke publicStroke = new BasicStroke(1.0f);

	// constructor
	public Tracing(Component cmp) {
		Method[] storedMethods = java.awt.Graphics.class.getMethods();
		int length = storedMethods.length;
		// results = test.split(":\\s*");
		for (int i = 0; i < length; i++) {
			methods.put(storedMethods[i].getName(), storedMethods[i]);
		}

		JRootPane jRoot = findRootPane(cmp);
		if (jRoot != null)
			root = findAllComp(jRoot);
		// JTree tree = new JTree(root);
		// frame.getContentPane().add(new JScrollPane(tree),
		// BorderLayout.CENTER);
		// frame.setSize(new Dimension (500, 500));
		// frame.pack();
		// frame.setVisible(true);
	}

	public static int getMethodHash(String name, Class[] args) {
		int hashcode = 0;

		try {
			Method method = java.awt.Graphics2D.class.getMethod(name, args);
			hashcode = method.toString().hashCode();
		} catch (SecurityException e) {

			e.printStackTrace();
		} catch (NoSuchMethodException e) {

			e.printStackTrace();
		}

		return hashcode;
	}

	public static JRootPane findRootPane(Component cmp) {

		if (cmp instanceof JRootPane) {
			return (JRootPane) cmp;
		}
		if (cmp.getParent() != null) {
			return findRootPane(cmp.getParent());
		}

		// this should not happen
		return null;
	}

	public static DefaultMutableTreeNode findAllComp(Container rt) {
		DefaultMutableTreeNode node = new DefaultMutableTreeNode(rt);

		Component[] component = rt.getComponents();
		DefaultMutableTreeNode child;
		for (Component cmp : component) {
			if (cmp instanceof Container) {
				child = findAllComp((Container) cmp);
			} else
				child = new DefaultMutableTreeNode(cmp);
			node.add(child);
		}
		return node;
	}

	public static aspect TracingOutput {

		// exit()
		pointcut captureExit():
			call (* java.lang.System.exit(*)) && if(stop == false) && ! within(record.*) && if(stop == false) && ! within(tracing.*) && if(stop == false);

		void around() : captureExit(){
			// System.out.println("No exit");
			try {
				postmortem.MyTool.main(null);
			} catch (IOException e) {

				e.printStackTrace();
			}
			stop = true;

		}

		pointcut rep() : call(* javax.swing.JComponent.paintComponent(..)) && ! within(record.*) && ! within(tracing.*) && if(stop == false);

		before() : rep(){
			/**
			 * publicComp = (Component) thisJoinPoint.getTarget();
			 * 
			 * if (!prova.contains(publicComp.hashCode())) {
			 * prova.add(publicComp.hashCode()); }
			 * 
			 * if (prova2.size() <= prova.size()) { if
			 * (!prova2.contains(publicComp.hashCode())) {
			 * prova2.add(publicComp.hashCode()); }
			 * 
			 * } else { prova2.clear(); prova2.add(publicComp.hashCode()); }
			 * 
			 * // Add this component to the HashMap that maps components and the
			 * // instrumented methods to paint them if
			 * (!objectMethods.containsKey(publicComp.hashCode()))
			 * objectMethods.put(publicComp.hashCode(), new
			 * ArrayList<MethodParam>()); // }
			 * 
			 * Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry =
			 * objectMethods .entrySet(); ArrayList<MethodParam> list = null;
			 * for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) { if
			 * (set.getKey() == publicComp.hashCode()) { list = set.getValue();
			 * list.clear(); } }
			 */
		}

		pointcut awtPaint(Graphics g) : call (* java.awt.Component.paint(Graphics)) && args(g) && ! within(record.*) && ! within(tracing.*) && if(stop == false);

		before(Graphics g) : awtPaint(g){

			publicGr = g;
			// affine = g2.getTransform();
			publicComp = (Component) thisJoinPoint.getTarget();

			if (!prova.contains(publicComp.hashCode())) {
				prova.add(publicComp.hashCode());
			}

			if (prova2.size() <= prova.size()) {
				if (!prova2.contains(publicComp.hashCode())) {
					prova2.add(publicComp.hashCode());
				}

			} else {
				prova2.clear();
				prova2.add(publicComp.hashCode());
			}

			// Add this component to the HashMap that maps components and the
			// instrumented methods to paint them
			if (!objectMethods.containsKey(publicComp.hashCode()))
				objectMethods.put(publicComp.hashCode(),
						new ArrayList<MethodParam>());
			// }

			Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
					.entrySet();
			ArrayList<MethodParam> list = null;
			for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
				if (set.getKey() == publicComp.hashCode()) {
					list = set.getValue();
					list.clear();
				}
			}

		}

		pointcut paintUI(Graphics g, JComponent c) : call (* javax.swing.plaf.ComponentUI.paint(Graphics, JComponent)) && args(g, c) && ! within(record.*) && ! within(tracing.*) && if(stop == false);

		before(Graphics g, JComponent c) : paintUI(g, c){
			// System.out.println("around: " + c.getLocationOnScreen());
			// publicComp = c;
		}

		pointcut captureSetColor(Color color) : call(* java.awt.Graphics.setColor(Color)) && args(color) && ! within(record.*) && ! within(tracing.*) && if(stop == false);

		before(Color color) : captureSetColor(color){
			publicColor = color;
			lastColorLocation = thisJoinPoint.getStaticPart()
					.getSourceLocation().toString();
		}

		pointcut captureSetStroke(Stroke stroke) : call(* java.awt.Graphics2D.setStroke(Stroke)) && args(stroke) && ! within(record.*) && ! within(tracing.*) && if(stop == false);

		before(Stroke stroke) : captureSetStroke(stroke){
			publicStroke = stroke;
		}

		// Capture execution of paintComponent methods This provides the
		// component that is being painted and the
		// graphics object used to paint it. Using the hashcode of the graphics
		// object I try to match which of the
		// graphics methods is used to paint which component so I can paint them
		// in the correct location on screen

		pointcut pse(Graphics pG) : call(* paintComponent*(Graphics)) && args(pG) && ! within(record.*) && ! within(tracing.*) && if(stop == false);

		after(Graphics pG) : pse(pG){

			Component comp = (Component) thisJoinPoint.getTarget();
			graphicsAndObjects.put(pG.hashCode(), pG);
			if (once) {
				JRootPane jRoot = findRootPane(comp);
				if (jRoot != null)
					root = findAllComp(jRoot);
				// System.out.println("JTree ok");
				once = false;
			}
		}

		pointcut pse3(Graphics g, JComponent c) : call(* javax.swing.plaf.ComponentUI.paint(Graphics, JComponent)) && args(g, c) && ! within(record.*) && ! within(tracing.*) && if(stop == false);

		after(Graphics g, JComponent c) : pse3(g, c){
			Graphics2D gg = (Graphics2D) g;
			AffineTransform f = gg.getTransform();
			// System.out.println("Plaf: " + gg.hashCode());
			graphicsAndObjects.put(g.hashCode(), g);
			publicComp = c;
		}

		// JFrame Constructor
		// Pointcut for JFrame construction. Use this main Frame to get the
		// bounds of the program being traced
		// Initialize a hashMap that maps each pixel with it's color and source
		// line that draws that pixel
		pointcut jFrame() : call (JFrame+.new(..)) && ! within(record.*) && ! within(tracing.*) && if (initially == true) && if(stop == false);

		after() returning(JFrame frame): jFrame() {
			Tracing t = new Tracing(frame);

			initially = false;
			mainFrame = frame;

			int w = mainFrame.getWidth();
			int h = mainFrame.getHeight();
			int id = 0;
			int color = Color.white.getRGB();
			String src = "none";

			if (w <= 0)
				w = 600;
			if (h <= 0)
				h = 600;

			// testimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_BGR);
			// Graphics2D gc = testimg.createGraphics();
			// gc.setColor(Color.white);
			// gc.fillRect(0, 0, w, h);

		}

		pointcut captureDrawString(String str, int x, int y) : call(* java.awt.Graphics.drawString(String, int, int)) && args(str, x, y) && ! within(record.*) && ! within(tracing.*) && if(stop == false);

		after(String str, int x, int y) : captureDrawString(str, x, y){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();
				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());
				Shape shape = null;

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[3];
				arguments[0] = str;
				arguments[1] = x;
				arguments[2] = y;

				command = new String();

				command = "drawString";

				end = System.currentTimeMillis();
				ex = end - start;
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();

				Integer[] o = new Integer[5];
				o[0] = y;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[3];
				argTypes[0] = String.class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is
				// being
				// painted
				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawRect(int x, int y, int width, int height)
		pointcut captureDrawRect(int x, int y, int width, int height) : 
			call(* java.awt.Graphics.drawRect(int, int, int, int)) && args(x, y, width, height) && ! within(tracing.*) && ! within(record.*) && if(stop == false);

		after(int x, int y, int width, int height) : captureDrawRect(x, y, width, height){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[4];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();

				command = "drawRect";

				end = System.currentTimeMillis();
				ex = end - start;
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];
				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is
				// being
				// painted
				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}

		}

		// clearRect(int x, int y, int width, int height)
		pointcut captureClearRect(int x, int y, int width, int height) : 
		call(* clearRect(int, int, int, int)) && args(x, y, width, height) && ! within(tracing.*) && ! within(record.*) && if(stop == false);

		after(int x, int y, int width, int height) : captureClearRect(x, y, width, height){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[4];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "clearRect";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is
				// being painted
				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}

		}

		// fillRect(int x, int y, int width, int height)
		pointcut captureFillRect(int x, int y, int width, int height) : 
				call(* java.awt.Graphics.fillRect(int, int, int, int)) && args(x, y, width, height) && ! within(tracing.*) && ! within(record.*)  && if(stop == false);

		after(int x, int y, int width, int height) : captureFillRect(x, y, width, height){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[4];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "fillRect";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is
				// being painted
				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawImagev5(Image img, int dx1, int dy1, int dx2, int dy2, int sx1,
		// int sy1, int sx2, int sy2, ImageObserver observer)
		// drawImagev(Image img, int dx1, int dy1, int dx2, int dy2, int sx1,
		// int sy1, int sx2, int sy2, ImageObserver observer)
		pointcut captureDrawImagev5(Image img, int dx1, int dy1, int dx2,
				int dy2, int sx1, int sy1, int sx2, int sy2,
				ImageObserver observer) :
					call(* java.awt.Graphics.drawImage(Image, int, int, int, int, int, int, int, int, ImageObserver)) && args (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer)
					&& ! within(tracing.*) && ! within(record.*)  && if(stop == false);

		after(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
				int sx2, int sy2, ImageObserver observer):
					captureDrawImagev5(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				dx1 = dx1 + (int) p.getX();
				dy1 = dy1 + (int) p.getY();
				dx2 = dx2 + (int) p.getX();
				dy2 = dy2 + (int) p.getY();
				// sx1 = sx1 + (int) p.getX();
				// sy1 = sy1 + (int) p.getY();
				// sx2 = sx2 + (int) p.getX();
				// sy2 = sy2 + (int) p.getY();

				Shape shape = new Rectangle(dx1, dy1, sx2, sy2);

				arguments = new Object[10];
				arguments[0] = img;
				arguments[1] = dx1;
				arguments[2] = dy1;
				arguments[3] = dx2;
				arguments[4] = dy2;
				arguments[5] = sx1;
				arguments[6] = sy1;
				arguments[7] = sx2;
				arguments[8] = sy2;
				arguments[9] = observer;

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawImage";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];
				o[0] = dx1;
				o[1] = dy1;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[10];
				argTypes[0] = Image.class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				argTypes[5] = Integer.TYPE;
				argTypes[6] = Integer.TYPE;
				argTypes[7] = Integer.TYPE;
				argTypes[8] = Integer.TYPE;
				argTypes[9] = ImageObserver.class;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is
				// being
				// painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}

				}
			}

		}

		// drawLine(int x1, int y1, int x2, int y2)
		pointcut captureDrawLine(int x1, int y1, int x2, int y2) :
				call(* java.awt.Graphics.drawLine(int, int, int, int)) && args(x1, y1, x2, y2) && ! within(tracing.*) && ! within(record.*) && if(stop == false);

		after(int x1, int y1, int x2, int y2) : captureDrawLine(x1, y1, x2, y2){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Graphics2D myG2 = (Graphics2D) myG;

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x1 = x1 + (int) p.getX();
				y1 = y1 + (int) p.getY();
				x2 = x2 + (int) p.getX();
				y2 = y2 + (int) p.getY();

				Object[] ar = new Object[4];

				arguments = new Object[4];
				arguments[0] = x1;
				arguments[1] = y1;
				arguments[2] = x2;
				arguments[3] = y2;

				command = new String();

				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;
				command = "drawLine";

				Shape shape = new Line2D.Double(x1, y1, x2, y2);

				Integer color = 0;

				Color c = Color.RED;
				color = c.getRGB();

				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];
				o[0] = x1;
				o[1] = y1;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is
				// being
				// painted
				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// fillRect(int x, int y, int width, int height)
		pointcut captureFillOval(int x, int y, int width, int height) : 
				call(* java.awt.Graphics.fillOval(int, int, int, int)) && args(x, y, width, height) && ! within(tracing.*) && ! within(record.*)  && if(stop == false);

		after(int x, int y, int width, int height) : captureFillRect(x, y, width, height){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[4];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "fillOval";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is
				// being painted
				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// clipRect(int x, int y, int width, int height) pointcut
		pointcut captureGetRect(int x, int y, int width, int height) : call(* java.awt.Graphics.clipRect(int, int, int, int)) 
		 && args(x, y, width, height) && ! within(tracing.*) && ! within(record.*) && if(stop == false);

		after(int x, int y, int width, int height) : captureGetRect(x, y,
		 width, height){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[4];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "clipRect";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted
				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawRoundRect(int x, int y, int width, int height, int arcWidth,
		// int arcHeight)
		pointcut captureDrawRoundRect(int x, int y, int width, int height,
				int arcWidth, int arcHeight) : 
			 call (* java.awt.Graphics.drawRoundRect(int, int, int, int, int, int)) &&
		 args(x, y, width, height, arcWidth, arcHeight) && within(tracing.*)
		 && ! within(record.*) && if(stop == false);

		after(int x, int y, int width, int height, int arcWidth, int arcHeight) : captureDrawRoundRect(x, y, width, height, arcWidth,
		 arcHeight){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[6];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;
				arguments[4] = arcWidth;
				arguments[5] = arcHeight;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawRoundRect";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[6];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				argTypes[5] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}

		}

		// fillRoundRect(int x, int y, int width, int height, int arcWidth,
		// int arcHeight)
		pointcut captureFillRoundRect(int x, int y, int width, int height,
				int arcWidth, int arcHeight) : call (*
		 java.awt.Graphics.fillRoundRect(int, int, int, int, int, int)) &&
		 args(x, y, width, height, arcWidth, arcHeight) && within(tracing.*)
		 && ! within(record.*) && if(stop == false);

		after(int x, int y, int width, int height, int arcWidth, int arcHeight) : captureFillRoundRect(x, y, width, height, arcWidth,
		 arcHeight){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[6];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;
				arguments[4] = arcWidth;
				arguments[5] = arcHeight;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "fillRoundRect";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[6];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				argTypes[5] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// draw3DRect(int x, int y, int width, int height, boolean raised) //
		// Overrides draw3DRect() in Graphics
		pointcut captureDraw3DRect(int x, int y, int width, int height,
				boolean raised) : call(*
		 java.awt.Graphics.draw3DRect(int, int, int, int, boolean)) && args(x,
		 y, width, height, raised) && ! within(tracing.*) && !
		 within(record.*) && if(stop == false);

		after(int x, int y, int width, int height, boolean raised) :
		 captureDraw3DRect(x, y, width, height, raised){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[5];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;
				arguments[4] = raised;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "draw3DRect";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[5];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = boolean.class;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted
				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// fill3DRect(int x, int y, int width, int height, boolean raised) //
		// Overrides draw3DRect() in Graphics
		pointcut captureFill3DRect(int x, int y, int width, int height,
				boolean raised) : call(*
		 java.awt.Graphics.fill3DRect(int, int, int, int, boolean)) && args(x,
		 y, width, height, raised) && ! within(tracing.*) && !
		 within(record.*) && if(stop == false);

		after(int x, int y, int width, int height, boolean raised) :
		 captureFill3DRect(x, y, width, height, raised){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[5];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;
				arguments[4] = raised;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "fill3DRect";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[5];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = boolean.class;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawArc(int x, int y, int width, int height, int startAngle, int
		// arcAngle)

		pointcut captureDrawArc(int x, int y, int width, int height,
				int startAngle, int arcAngle) : call(*
		 java.awt.Graphics.drawArc(int, int, int, int, int, int)) && args (x,
		 y, width, height, startAngle, arcAngle) && ! within(tracing.*) && !
		 within(record.*) && if(stop == false);

		after(int x, int y, int width, int height, int startAngle, int arcAngle) : captureDrawArc(x, y, width, height, startAngle,
		 arcAngle){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[6];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;
				arguments[4] = startAngle;
				arguments[5] = arcAngle;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawArc";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[6];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				argTypes[5] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// fillArc(int x, int y, int width, int height, int startAngle, int
		// arcAngle)

		pointcut captureFillArc(int x, int y, int width, int height,
				int startAngle, int arcAngle) : call(*
		 java.awt.Graphics.fillArc(int, int, int, int, int, int)) && args (x,
		 y, width, height, startAngle, arcAngle) && ! within(tracing.*) && !
		 within(record.*) && if(stop == false);

		after(int x, int y, int width, int height, int startAngle, int arcAngle) : captureFillArc(x, y, width, height, startAngle,
		 arcAngle){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[6];
				arguments[0] = x;
				arguments[1] = y;
				arguments[2] = width;
				arguments[3] = height;
				arguments[4] = startAngle;
				arguments[5] = arcAngle;

				Shape shape = new Rectangle(x, y, width, height);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "fillArc";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[6];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				argTypes[5] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawPolyline(int[] xPoints, int[] yPoints, int nPoints)

		pointcut captureDrawPolyline(int[] xPoints, int[] yPoints, int nPoints) : 
			 call(* java.awt.Graphics.drawPolyline(int[], int[], int)) && args(xPoints, yPoints, nPoints) && ! within(tracing.*) 
		 && ! within(record.*) && if(stop == false);

		after(int[] xPoints, int[] yPoints, int nPoints) :
		 captureDrawPolyline(xPoints, yPoints, nPoints){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				for (int x : xPoints)
					x = x + (int) p.getX();
				for (int y : yPoints)
					y = y + (int) p.getY();

				arguments = new Object[3];
				arguments[0] = xPoints;
				arguments[1] = yPoints;
				arguments[2] = nPoints;

				int xSize = xPoints.length;
				int ySize = yPoints.length;

				Shape shape = new Rectangle(xPoints[0], yPoints[0], xPoints[0]
						+ xPoints[xSize - 1], yPoints[0] + yPoints[ySize - 1]);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawPolyLine";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = xPoints[0];
				o[1] = yPoints[0];
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[3];
				argTypes[0] = Integer[].class;
				argTypes[1] = Integer[].class;
				argTypes[2] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}

		}

		// drawPolygon(int[] xPoints, int[] yPoints, int nPoints) pointcut
		pointcut captureDrawPolygon(int[] xPoints, int[] yPoints, int nPoints) :
		 call(* java.awt.Graphics.drawPolygon(int[], int[], int)) &&
		 args(xPoints, yPoints, nPoints) && ! within(tracing.*) && !
		 within(record.*) && if(stop == false);

		after(int[] xPoints, int[] yPoints, int nPoints) :
		 captureDrawPolygon(xPoints, yPoints, nPoints){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				for (int x : xPoints)
					x = x + (int) p.getX();
				for (int y : yPoints)
					y = y + (int) p.getY();

				arguments = new Object[3];
				arguments[0] = xPoints;
				arguments[1] = yPoints;
				arguments[2] = nPoints;

				int xSize = xPoints.length;
				int ySize = yPoints.length;

				Shape shape = new Rectangle(xPoints[0], yPoints[0], xPoints[0]
						+ xPoints[xSize - 1], yPoints[0] + yPoints[ySize - 1]);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawPolygon";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = xPoints[0];
				o[1] = yPoints[0];
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[3];
				argTypes[0] = Integer[].class;
				argTypes[1] = Integer[].class;
				argTypes[2] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}

		}

		// fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
		pointcut captureFillPolygon(int[] xPoints, int[] yPoints, int nPoints) :
		 call(* java.awt.Graphics.drawPolygon(int[], int[], int)) &&
		 args(xPoints, yPoints, nPoints) && ! within(tracing.*) && !
		 within(record.*) && if(stop == false);

		after(int[] xPoints, int[] yPoints, int nPoints) :
		 captureFillPolygon(xPoints, yPoints, nPoints){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				for (int x : xPoints)
					x = x + (int) p.getX();
				for (int y : yPoints)
					y = y + (int) p.getY();

				arguments = new Object[3];
				arguments[0] = xPoints;
				arguments[1] = yPoints;
				arguments[2] = nPoints;

				int xSize = xPoints.length;
				int ySize = yPoints.length;

				Shape shape = new Rectangle(xPoints[0], yPoints[0], xPoints[0]
						+ xPoints[xSize - 1], yPoints[0] + yPoints[ySize - 1]);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "fillPolygon";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = xPoints[0];
				o[1] = yPoints[0];
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[3];
				argTypes[0] = Integer[].class;
				argTypes[1] = Integer[].class;
				argTypes[2] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawPolygon(Polygon p)
		pointcut captureDrawPolygon1(Polygon polygon) : call(* java.awt.Graphics.drawPolygon(Polygon)) &&
		 args(polygon) && ! within(tracing.*) && ! within(record.*) && if(stop
		 == false);

		after(Polygon polygon) : captureDrawPolygon1(polygon){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				int x = (int) polygon.getBounds2D().getMinX();
				int y = (int) polygon.getBounds2D().getMinY();

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[1];
				arguments[0] = polygon;

				Shape shape = polygon;

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawPolygon";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		pointcut captureFillPolygon1(Polygon polygon) : call(*
		 java.awt.Graphics.drawPolygon(Polygon)) && args(polygon) && !
		 within(tracing.*) && ! within(record.*) && if(stop == false);

		after(Polygon polygon) : captureFillPolygon1(polygon){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				int x = (int) polygon.getBounds2D().getMinX();
				int y = (int) polygon.getBounds2D().getMinY();

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[1];
				arguments[0] = polygon;

				Shape shape = polygon;

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "fillPolygon";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Integer.TYPE;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawString(AttributeCharacterIterator iterator, int x, int y)
		pointcut captureDrawStringv2(AttributedCharacterIterator iterator,
				int x, int y) : call(* java.awt.Graphics.drawString(AttributedCharacterIterator, int, int))
		 && args(iterator, x, y) && ! within(tracing.*) && ! within(record.*)
		 && if(stop == false);

		after(AttributedCharacterIterator iterator, int x, int y) :
		 captureDrawStringv2(iterator, x, y){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[3];
				arguments[0] = iterator;
				arguments[1] = x;
				arguments[2] = y;

				Shape shape = new Rectangle((int) x, (int) y, (int) x + 10,
						(int) y + 10);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawString";

				Integer color = publicComp.getBackground().getRGB();
				color = Color.red.getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = (int) x;
				o[1] = (int) y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[3];
				argTypes[0] = AttributedCharacterIterator.class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawChars(char[] data, int offset, int length, int x, int y)
		pointcut captureDrawChars(char[] data, int offset, int length, int x,
				int y) : call(* java.awt.Graphics.drawChars(char[], int, int, int,
		 int)) && args(data, offset, length, x, y) && ! within(tracing.*) && !
		 within(record.*) && if(stop == false);

		after(char[] data, int offset, int length, int x, int y) :
		 captureDrawChars(data, offset, length, x, y){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[5];
				arguments[0] = data;
				arguments[1] = offset;
				arguments[2] = length;
				arguments[3] = x;
				arguments[4] = y;

				Shape shape = new Rectangle(x, y, x + 10, y + 10);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawChars";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[5];
				argTypes[0] = char[].class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawBytes(char[] data, int offset, int length, int x, int y)
		pointcut captureDrawBytes(char[] data, int offset, int length, int x,
				int y) : call(* java.awt.Graphics.drawBytes(char[], int, int, int,
		 int)) && args(data, offset, length, x, y) && ! within(tracing.*) && !
		 within(record.*) && if(stop == false);

		after(char[] data, int offset, int length, int x, int y) :
		 captureDrawBytes(data, offset, length, x, y){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[5];
				arguments[0] = data;
				arguments[1] = offset;
				arguments[2] = length;
				arguments[3] = x;
				arguments[4] = y;

				Shape shape = new Rectangle(x, y, x + 10, y + 10);

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawBytes";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[5];
				argTypes[0] = char[].class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawImagev1(Image img, int x, int y, ImageObserver observer)
		pointcut captureDrawImagev1(Image img, int x, int y,
				ImageObserver observer) : 
		call(* java.awt.Graphics.drawImage(Image, int, int, ImageObserver)) && args(img, x, y, observer) && ! within(tracing.*) && ! within(record.*) && if(stop == false);

		after(Image img, int x, int y, ImageObserver observer) returning(boolean result) : captureDrawImagev1(img, x, y, observer){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[4];
				arguments[0] = img;
				arguments[1] = x;
				arguments[2] = y;
				arguments[3] = observer;

				Shape shape = new Rectangle(x, y, img.getWidth(observer),
						img.getHeight(observer));

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawImage";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Image.class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = ImageObserver.class;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is
				// being painted
				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawImagev2(Image img, int x, int y, int width, int height, //
		// ImageObserver observer)

		pointcut captureDrawImagev2(Image img, int x, int y, int width,
				int height, ImageObserver observer): call(*
		 java.awt.Graphics.drawImage(Image, int, int, int, int,
		 ImageObserver)) && args(img, x, y, width, height, observer) && !
		 within(tracing.*) && ! within(record.*) && if(stop == false);

		after(Image img, int x, int y, int width, int height,
				ImageObserver observer) returning(boolean result) : captureDrawImagev2(img, x, y,
		 width, height, observer){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[6];
				arguments[0] = img;
				arguments[1] = x;
				arguments[2] = y;
				arguments[3] = width;
				arguments[4] = height;
				arguments[5] = observer;

				Shape shape = new Rectangle(x, y, img.getWidth(observer),
						img.getHeight(observer));

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawImage";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[6];
				argTypes[0] = Image.class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				argTypes[5] = ImageObserver.class;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawImagev3(Image img, int x, int y, Color bgcolor, ImageObserver
		// observer)

		pointcut captureDrawImagev3(Image img, int x, int y, Color color1,
				ImageObserver observer) : call(*
		  java.awt.Graphics.drawImage(Image, int, int, Color, ImageObserver))
		  && args(img, x, y, color1, observer) && ! within(tracing.*) && !
		  within(record.*) && if(stop == false);

		after(Image img, int x, int y, Color color1, ImageObserver observer)
		  returning(boolean result) : captureDrawImagev3(img, x, y, color1,
		  observer){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[5];
				arguments[0] = img;
				arguments[1] = x;
				arguments[2] = y;
				arguments[3] = color1;
				arguments[4] = observer;

				Shape shape = new Rectangle(x, y, img.getWidth(observer),
						img.getHeight(observer));

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawImage";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[4];
				argTypes[0] = Image.class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Color.class;
				argTypes[4] = ImageObserver.class;
				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawImagev4(Image img, int x, int y, int width, int height, Color
		// color, ImageObserver observer)

		pointcut captureDrawImagev4(Image img, int x, int y, int width,
				int height, Color color1, ImageObserver observer) : call(* java.awt.Graphics.drawImage(Image, int, int, int,
		  int, Color, ImageObserver)) && args(img, x, y, width, height, color1,
		  observer) && ! within(tracing.*) && ! within(record.*) && if(stop ==
		  false);

		after(Image img, int x, int y, int width, int height, Color color1,
				ImageObserver observer) returning(boolean result) :
		  captureDrawImagev4(img, x, y, width, height, color1, observer){
			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				x = x + (int) p.getX();
				y = y + (int) p.getY();

				arguments = new Object[7];
				arguments[0] = img;
				arguments[1] = x;
				arguments[2] = y;
				arguments[3] = width;
				arguments[4] = height;
				arguments[5] = color1;
				arguments[6] = observer;

				Shape shape = new Rectangle(x, y, img.getWidth(observer),
						img.getHeight(observer));

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawImage";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = x;
				o[1] = y;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[7];
				argTypes[0] = Image.class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				argTypes[5] = Color.class;
				argTypes[6] = ImageObserver.class;

				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

		// drawImagev6(Image img, int dx1, int dy1, int dx2, int dy2, int
		// sx1, // int sx2, int sy2, Color color, ImageObserver observer)

		pointcut captureDrawImagev6(Image img, int dx1, int dy1, int dx2,
				int dy2, int sx1, int sy1, int sx2, int sy2, Color color1,
				ImageObserver observer) : call(* java.awt.Graphics.drawImage(Image, int, int, int,
		  int, int, int, int, int, Color, ImageObserver)) && args(img, dx1,
		  dy1, dx2, dy2, sx1, sy1, sx2, sy2, color1, observer) && !
		  within(tracing.*) && ! within(record.*) && if(stop == false);

		after(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
				int sx2, int sy2, Color color1, ImageObserver observer)
		  returning (boolean result) : captureDrawImagev6(img, dx1, dy1, dx2,
		  dy2, sx1, sy1, sx2, sy2, color1, observer){

			if (publicComp != null) {
				Graphics myG = (Graphics) thisJoinPoint.getTarget();

				Point p = new Point(publicComp.getLocationOnScreen());
				SwingUtilities.convertPointFromScreen(p,
						mainFrame.getRootPane());

				dx1 = dx1 + (int) p.getX();
				dy1 = dy1 + (int) p.getY();

				dx2 = dx2 + (int) p.getX();
				dy2 = dy2 + (int) p.getY();

				arguments = new Object[11];
				arguments[0] = img;
				arguments[1] = dx1;
				arguments[2] = dy1;
				arguments[3] = dx2;
				arguments[4] = dy2;
				arguments[5] = sx1;
				arguments[6] = sy1;
				arguments[7] = sx2;
				arguments[8] = sy2;
				arguments[9] = color1;
				arguments[10] = observer;

				Shape shape = new Rectangle(dx1, dy1, img.getWidth(observer),
						img.getHeight(observer));

				command = new String();
				sourceLocation = thisJoinPoint.getStaticPart()
						.getSourceLocation().toString();
				end = System.currentTimeMillis();
				ex = end - start;

				command = "drawImage";

				Integer color = publicComp.getBackground().getRGB();
				int pX = publicComp.getX()
						+ (int) publicComp.getLocationOnScreen().getX();
				int pY = publicComp.getY()
						+ (int) publicComp.getLocationOnScreen().getY();
				int pWidth = (int) publicComp.getWidth();
				int pHeight = (int) publicComp.getHeight();
				Integer[] o = new Integer[5];

				o[0] = dx1;
				o[1] = dy1;
				o[2] = pWidth;
				o[3] = pHeight;
				o[4] = color;

				Class argTypes[] = new Class[11];
				argTypes[0] = Image.class;
				argTypes[1] = Integer.TYPE;
				argTypes[2] = Integer.TYPE;
				argTypes[3] = Integer.TYPE;
				argTypes[4] = Integer.TYPE;
				argTypes[5] = Integer.TYPE;
				argTypes[6] = Integer.TYPE;
				argTypes[7] = Integer.TYPE;
				argTypes[8] = Integer.TYPE;
				argTypes[9] = Color.class;
				argTypes[10] = ImageObserver.class;

				int methodHash = 0;
				methodHash = getMethodHash(command, argTypes);

				// Map this method instrumentation with the component that is //
				// being painted

				Set<Map.Entry<Integer, ArrayList<MethodParam>>> entry = objectMethods
						.entrySet();
				ArrayList<MethodParam> list = null;
				for (Map.Entry<Integer, ArrayList<MethodParam>> set : entry) {
					if (set.getKey() == publicComp.hashCode()) {
						list = set.getValue();
						list.add(new MethodParam(command, arguments,
								sourceLocation, ex, publicGr, publicComp,
								publicColor, publicStroke, shape,
								lastColorLocation, methodHash));
					}
				}
			}
		}

	}
}